#pragma once
#include"rbtree.h"
namespace wang
{
	template<class K, class T>
	class map
	{
	public:
		struct Mapkot
		{
			const K& operator()(const pair<K, T>& kv)
			{
				return kv.first;
			}
		};
		typedef typename rbtree<K, pair<K, T>, Mapkot>::Iterator iterator;
		pair<iterator, bool> insert(const pair<K, T>& kv)
		{
			return _tree.insert(kv);
		}

		iterator find(const K& key)
		{
			return _tree.find(key);
		}
		iterator begin()
		{
			return _tree.Begin();
		}
		iterator end()
		{
			return _tree.End();
		}
		T& operator[](const K& key)
		{
			auto p = _tree.insert({ key, T() });
			return p.first->second;
		}
	private:
		rbtree<K, pair<K, T>, Mapkot> _tree;
	};
}